package ltd.smallwang.app.user.convert;

import cn.hutool.core.util.DesensitizedUtil;
import ltd.smallwang.client.user.dto.UserDto;
import ltd.smallwang.infrastructure.user.db.model.UserPO;
import ltd.smallwang.infrastructure.util.CryptoUtil;

/**
 * @author justd
 * @description 功能描述
 * @since 2024-05-05 16:15
 **/
public interface UserConvert {

  static UserDto convert(UserPO userPo) {
    UserDto result = new UserDto();
    result.setUsername(userPo.getUsername());
    result.setNickName(userPo.getNickName());
    result.setAvatarUrl(userPo.getAvatar());
    result.setEmail(DesensitizedUtil.email(CryptoUtil.decrypt(userPo.getEmail())));
    return result;
  }
}
